
package com.hlkj.pay.app.merchant.ext.impl.kuaiqian.util;

import com.bill99.crypto.entity.Bill99CertConfig;
import com.hlkj.pay.app.merchant.ext.impl.kuaiqian.dto.Bill99AppChannelParams;

public class Bill99CertConfigLoader {

    private static final Bill99CertConfig config = new Bill99CertConfig();

    public static Bill99CertConfig loadConfig(Bill99AppChannelParams bill99AppChannelParams) {

        // 默认证书配置
        config.setMerchantDefaultPrivatePath(bill99AppChannelParams.getPrivatePath());
        config.setMerchantDefaultPrivatePassword(bill99AppChannelParams.getPrivatePassword());
        config.setBill99DefaultPublicPath(bill99AppChannelParams.getPublicPath());
        /*
         * //备用证书或过渡性证书配置，只有一套证书的情况下备用证书可以不配置
         * config.setMerchantAlternatePrivatePath(Bill99ConfigInfo.AL_PRI_PATH);
         * config.setMerchantAlternatePrivatePassword(Bill99ConfigInfo.AL_PRI_PWD);
         * config.setBill99AlternatePublicPath(Bill99ConfigInfo.AL_PUB_PATH);
         */
        return config;

    }

    /**
     * 构建证书配置
     * 
     * @param certPath
     *            私钥证书路径
     * @param certPwd
     *            私钥证书密码
     * @param publicCertPath
     *            公钥证书路径
     * @return 证书路径配置信息
     */
    public static Bill99CertConfig buildBill99CertConfig(String certPath, String certPwd, String publicCertPath) {
        Bill99CertConfig certConfig = new Bill99CertConfig();
        certConfig.setMerchantDefaultPrivatePath(certPath);
        certConfig.setMerchantDefaultPrivatePassword(certPwd);
        certConfig.setBill99DefaultPublicPath(publicCertPath);
        return certConfig;
    }

}
